*****************************************************
* Mexico Pollfish Survey            				*
* E1 Survey Experiment      				        *
* Ana López García, Sarah Berens & Barry Maydom 	*
* July 2023                                         *
* 		                            				*
* PLOTS - TEXT	                                    *
* Pollfish Mexico Survey Dec 31-Jan2nd 21/22        *
*****************************************************

*CHECK - Set directory

*Plots - Text 

use "Data/Data ready E1.dta", clear 

cd "Results/Plots E1/"


********************************************************
**PLOTS
****Figure 1 - Returning migrants
****Figure 2 - Healthcare access US
****Figure 3 - US Migration enforcement
*********************************************************

**************
***FIGURE 1***
**************
graph drop _all
****************************************************
*Non-migrant VS Returning and Non-returning MIGRANTS  
grstyle init 
grstyle set plain, nogrid
grstyle set color mono
grstyle set legend, nobox

*Plotting Main Effects
*Plots - tax instruments
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.return
margins g.E1_vign1@return, contrast(nowald pveffects) asobserved
marginsplot, x(E1_vign1) xtitle("") plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) byopt(title("") ///
	compact rows(1)) by(return, label ("Non-migrant HH" "Current + returning migrant HH" "Current migrant HH")) ///
	recast(scatter) recastci(rspike)  graphregion(color(white)) xlabel(0 "Generic" 1 "VAT" 2 "Income", labsize(small)) ///
	plot1opts(msymbol(oh)) ytitle("") yscale(range(-0.5 0.5))
graph save "Return_Instruments.gph", replace 

*Plots - tax earmarking 
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.return
margins g.E1_vign2@return, contrast(nowald pveffects) asobserved
marginsplot, x(E1_vign2) xtitle("") plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) byopt(title("") ///
	compact rows(1)) by(return, label ("Non-migrant HH" "Current + returning migrant HH" "Current migrant HH")) ///
	recast(scatter)  recastci(rspike)  graphregion(color(white)) xlabel(0 "Generic" 1 "Health" 2 "Roads" 3 "Security", labsize(small)) ///
	plot1opts(msymbol(oh)) ytitle("") yscale(range(-0.5 0.5))
graph save "Return_Earmarking.gph", replace 

**COMBINING GRAPHS (test) 
grstyle set graphsize 5.5 6 
graph combine "Return_Instruments.gph" "Return_Earmarking.gph", l1("Deviation from grand mean", size("vsmall")) ycommon cols(1) scale(0.9)
graph save "Figure1c.gph", replace 
graph export "Figure1c.wmf", as(wmf) replace



****************************************************
* US LOCAL CONTEXT 

**************
***FIGURE 2***
**************

*POST ENACTMENT ACCESS TO MEDICAID 
*Plots - tax instruments
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.medicaid2
margins g.E1_vign1@medicaid2, contrast(nowald pveffects) asobserved
marginsplot, x(E1_vign1) plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) ///
	byopt(title("Medicaid - Tax instrument", size(medlarge) margin(medsmall)) compact rows(1)) ///
	by(medicaid2, label ("Non-migrant HH" "Medicaid 5-year bar" "No waiting period"))  ///
	recast(scatter)  recastci(rspike)  graphregion(color(white)) xlabel(0 "Generic" 1 "VAT" 2 "Income", labsize(medsmall)) ///
	plot1opts(msymbol(oh)) ytitle("") xtitle("") yscale(range(-0.5 0.5))
graph save "Medicaid_Instruments.gph", replace 

*Plots - tax earmarking 
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.medicaid2 
margins g.E1_vign2@medicaid2, contrast(nowald pveffects) asobserved
marginsplot, x(E1_vign2) plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) ///
	byopt(title("Medicaid - Tax earmarking", size(medlarge) margin(medsmall)) compact rows(1)) ///
	by(medicaid2, label ("Non-migrant HH" "Medicaid 5-year bar" "No waiting period" )) ///
	recast(scatter)  recastci(rspike)  graphregion(color(white)) ///
	xlabel(0 "Generic" 1 "Health" 2 "Roads" 3 "Security", labsize(medsmall)) plot1opts(msymbol(oh)) ///
	ytitle("") xtitle("") yscale(range(-0.5 0.5))
graph save "Medicaid_Earmarking.gph", replace 

*SOCIAL ASSISTANCE PROGRAMS 
*Plots - tax instruments
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.assistance_us
margins g.E1_vign1@assistance_us, contrast(nowald pveffects) asobserved
marginsplot,  x(E1_vign1) plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) ///
	byopt(title("Welfare assistance - Tax instrument", size(medlarge) margin(medsmall)) compact rows(1)) ///
	by(assistance_us, label ("Non-migrant HH" "Less generous state" "More generous state")) ///
	recast(scatter)  recastci(rspike)  graphregion(color(white)) xlabel(0 "Generic" 1 "VAT" 2 "Income", labsize(medsmall)) ///
	plot1opts(msymbol(oh)) ytitle("") xtitle("") yscale(range(-0.5 0.5))
graph save "Welfare_Instruments.gph", replace 

*Plots - tax earmarking 
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.assistance_us 
margins g.E1_vign2@assistance_us, contrast(nowald pveffects) asobserved
marginsplot, x(E1_vign2) plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) ///
	byopt(title("Welfare assistance - Tax earmarking", size(medlarge) margin(medsmall)) compact rows(1)) ///
	by(assistance_us, label ("Non-migrant HH" "Less generous state" "More generous state")) ///
	recast(scatter)  recastci(rspike)  graphregion(color(white)) ///
	xlabel(0 "Generic" 1 "Health" 2 "Roads" 3 "Security", labsize(medsmall)) plot1opts(msymbol(oh)) ///
	ytitle("") xtitle("") yscale(range(-0.5 0.5))
graph save "Welfare_Earmarking.gph", replace 

**FIGURE 2 - COMBINING GRAPHS (test) 
grstyle set graphsize 5.75 12 
graph combine "Medicaid_Instruments.gph"  "Medicaid_Earmarking.gph", ycommon cols(2)  
graph save "Figure2a.gph", replace 

grstyle set graphsize 5.75 12 
graph combine "Welfare_Instruments.gph"  "Welfare_Earmarking.gph", ycommon cols(2)  
graph save "Figure2b.gph", replace 

grstyle set graphsize 5.75 12
graph combine "Figure2a.gph" "Figure2b.gph", l1("Deviation from grand mean", size("vsmall")) ycommon cols(1)  
graph save "Figure2c.gph", replace 
graph export "Figure2c.wmf", as(wmf) replace


**************
***FIGURE 3***
**************
********************************
*E-VERIFY (three category)
recode everify 1=1 2/3=2, gen(everifya)

*US states where E-Verify (all employers, and others) mandates are in place 
*Plots - tax instruments
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.everifya
margins g.E1_vign1@everifya, contrast(nowald pveffects) asobserved
marginsplot, x(E1_vign1) plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) ///
	byopt(title("E-Verify - Tax instrument", size(medlarge) margin(medsmall)) compact rows(1)) ///
	by(everifya, label ("Non-migrant HH"  "E-Verify mandatory" "E-Verify nonmandatory")) ///
	recast(scatter)  recastci(rspike)  graphregion(color(white)) xlabel(0 "Generic" 1 "VAT" 2 "Income", labsize(medsmall)) ///
	plot1opts(msymbol(oh)) ytitle("") xtitle("") yscale(range(-1 1))
graph save "Everify_Instruments.gph", replace 

*Plots - tax earmarking 
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.everifya
margins g.E1_vign2@everifya, contrast(nowald pveffects) asobserved
marginsplot, x(E1_vign2) plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) ///
	byopt(title("E-Verify - Tax earmarking", size(medlarge) margin(medsmall)) compact rows(1)) ///
	by(everifya, label ("Non-migrant HH"  "E-Verify mandatory" "E-Verify nonmandatory")) recast(scatter) ///
	recastci(rspike)  graphregion(color(white)) xlabel(0 "Generic" 1 "Health" 2 "Roads" 3 "Security", labsize(medsmall)) ///
	plot1opts(msymbol(oh)) ytitle("") xtitle("") yscale(range(-1 1))
graph save "Everify_Earmarking.gph", replace 

*******************************
*POLICE OMINIBUS MIGRATION LAWS
*Plots - tax instruments
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.police_us
margins g.E1_vign1@police_us, contrast(nowald pveffects) asobserved
marginsplot, x(E1_vign1) plotregion(margin(vlarge)) yline(0, lcolor(black) lpat(shortdash)) ///
	byopt(title("Police enforcement - Tax instrument", size(medlarge) margin(medsmall)) compact rows(1)) ///
	by(police_us, label ("Non-migrant HH"  "Police enforcement" "No enforcement")) recast(scatter)  recastci(rspike) ///
	graphregion(color(white)) xlabel(0 "Generic" 1 "VAT" 2 "Income", labsize(medsmall)) plot1opts(msymbol(oh)) ///
	ytitle("") xtitle("") yscale(range(-1 1))
graph save "Police_Instruments.gph", replace 

*Plots - tax earmarking 
anova E1_pay_taxes i.E1_vign1##i.E1_vign2##i.police_us
margins g.E1_vign2@police_us, contrast(nowald pveffects) asobserved
marginsplot, plotregion(margin(vlarge)) x(E1_vign2) yline(0, lcolor(black) lpat(shortdash)) ///
	byopt(title("Police enforcement - Tax earmarking", size(medlarge) margin(medsmall)) compact rows(1)) ///
	by(police_us, label ("Non-migrant HH" "Police enforcement" "No enforcement")) recast(scatter)  recastci(rspike) ///
	graphregion(color(white)) xlabel(0 "Generic" 1 "Health" 2 "Roads" 3 "Security", labsize(medsmall)) plot1opts(msymbol(oh)) ///
	ytitle("") xtitle("") yscale(range(-1 1))
graph save "Police_Earmarking.gph", replace 

*************************************************
***COMBINING GRAPHS - FIGURE 3 
grstyle set graphsize 5.75 12
graph combine "Everify_Instruments.gph" "Everify_Earmarking.gph" , ycommon cols(2) 
graph save "Figure3a.gph", replace 

grstyle set graphsize 5.75 12
graph combine "Police_Instruments.gph" "Police_Earmarking.gph", ycommon cols(2) 
graph save "Figure3b.gph", replace 

grstyle set graphsize 5.75 12
graph combine "Figure3a.gph" "Figure3b.gph", l1("Deviation from grand mean", size("vsmall")) cols(1)  scale(1.025)
graph save "Figure3c.gph", replace 
graph export "Figure3c.wmf", as(wmf) replace

